import { SelectionModel, TextModel } from "../models"
import { SourcePreview } from "./SourcePreview"
import { RenderView } from "./SourceView"

export type ViewMode = "source" | "render" | "source_preview"
export class ViewProvider {
  provide(
    viewMode: ViewMode,
    textModel: TextModel,
    selectionModel: SelectionModel,
    viewContainer: HTMLElement,
  ) {
    if (viewMode === "source") {
      return new RenderView(textModel, selectionModel, viewContainer)
    }
    if (viewMode === "source_preview") {
      return new SourcePreview(textModel, selectionModel, viewContainer)
    }
    return new RenderView(textModel, selectionModel, viewContainer)
  }
}
